molt_dat <- read.csv("../data/wl_molt_dat.csv")
# read in .csv
# contains information from WL 2022
# used for preliminary graphs
molt_dat_2 <- read.csv("../data/wl_cml_molt_dat.csv")
# read in updated .csv
# contains information from 2021, 2022, CML, and WL
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(car)
## Loading required package: carData
##
## Attaching package: 'car'
## The following object is masked from 'package:dplyr':
##
## recode
library(ggplot2)
# load relevant libraries for stats analysis
# 2022 WL crabs
plot(hemo_ri ~ days_from_molt, data = molt_dat,
main = "Hemolymph RI as Green Crabs Approach Molt (n=13)",
xlim = rev(range(days_from_molt)),
xlab = "Days From Molt",
ylab = "Hemolymph RI",
type = "b")
abline(lm (hemo_ri ~ days_from_molt, data = molt_dat), col = 4, lwd = 3)

# plots hemo ri vs days from molt for all 13 crabs
# need to reverse x axis to count down to molt
# appears to be downward trend in hemolymph RI as crabs approach molt
# need to investigate on an individual level
# WL and CML 2021-2022
plot(hemo_ri ~ days_from_molt, data = molt_dat_2,
main = "Hemolymph RI as Green Crabs Approach Molt (n=36)",
xlim = rev(range(days_from_molt)),
xlab = "Days From Molt",
ylab = "Hemolymph RI")
abline(lm (hemo_ri ~ days_from_molt, data = molt_dat), col = 4, lwd = 3)

# WL 2022 data
molt_dat %>%
# pipes molt data into ggplot
ggplot(aes(x = days_from_molt, y = hemo_ri)) +
# populates plot with hemo ri info and defines color with crab ID
geom_point() + geom_smooth(method=lm) +
# specifies type of plot -- linear model with 95 percent confidence
scale_x_reverse() +
# reverses x axis so information counts down to molt
xlab("Days from molt") +
ylab ("Hemolymph RI") +
ggtitle("Hemolymph protein as green crabs approach molt")
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 5 rows containing non-finite values (stat_smooth).
## Warning: Removed 5 rows containing missing values (geom_point).

# renames x and y labels and title
# WL 2022 data
molt_dat %>%
# pipes molt data into ggplot
ggplot(aes(x = days_from_molt, y = hemo_ri)) +
# populates plot with hemo ri info and defines color with crab ID
geom_point() + geom_smooth(method=lm, se=FALSE) +
# specifies type of plot -- linear model without confidence int
scale_x_reverse() +
# reverses x axis so information counts down to molt
xlab("Days from molt") +
ylab ("Hemolymph RI") +
ggtitle("Hemolymph RI as green crabs approach molt (n = 13)")
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 5 rows containing non-finite values (stat_smooth).
## Warning: Removed 5 rows containing missing values (geom_point).

# renames x and y labels and title
# WL 2022 data
library(ggplot2)
library(dplyr)
molt_dat %>%
# pipes molt data into ggplot
ggplot(aes(x = days_from_molt, y = hemo_ri, colour = crab_id)) +
# populates plot with hemo ri info and defines color with crab ID
geom_point() + geom_line() +
# specifies type of plot - scatter linear plot with crab IDs
scale_x_reverse() +
# reverses x axis so information counts down to molt
xlab("Days from molt") +
ylab ("Hemolymph RI") +
ggtitle("Hemolymph RI as green crabs approach molt (n = 13)") +
# renames x and y labels and title
labs(col = "Crab ID")
## Warning: Removed 5 rows containing missing values (geom_point).
## Warning: Removed 5 row(s) containing missing values (geom_path).

# changes legend title
# WL 2022 data
library(ggplot2)
library(dplyr)
molt_dat %>%
# pipes molt data into ggplot
ggplot(aes(x = days_from_molt, y = hemo_ri, colour = crab_id)) +
# populates plot with hemo ri info and defines color with crab ID
geom_point() + geom_line() +
# specifies type of plot - scatter linear plot with crab ids
scale_x_reverse() +
# reverses x axis so information counts down to molt
xlab("Days from molt") +
ylab ("Hemolymph RI") +
ggtitle("Hemolymph RI as green crabs approach molt") +
# renames x and y labels and title
labs(col = "Crab ID") +
# changes legend title
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.background = element_blank())
## Warning: Removed 5 rows containing missing values (geom_point).
## Warning: Removed 5 row(s) containing missing values (geom_path).

# removes background grid from plot
# WL 2022 data
ri_mod <- lm(hemo_ri ~ days_from_molt, data = molt_dat)
summary(ri_mod)
##
## Call:
## lm(formula = hemo_ri ~ days_from_molt, data = molt_dat)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.3899 -1.7526 -0.1578 1.9173 4.3814
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 5.75255 0.49221 11.687 < 2e-16 ***
## days_from_molt 0.17321 0.04246 4.079 0.000137 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.238 on 59 degrees of freedom
## (5 observations deleted due to missingness)
## Multiple R-squared: 0.22, Adjusted R-squared: 0.2068
## F-statistic: 16.64 on 1 and 59 DF, p-value: 0.0001374
anova(ri_mod)
## Analysis of Variance Table
##
## Response: hemo_ri
## Df Sum Sq Mean Sq F value Pr(>F)
## days_from_molt 1 83.31 83.310 16.64 0.0001374 ***
## Residuals 59 295.39 5.007
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
car::Anova(ri_mod, type = 3)
## Anova Table (Type III tests)
##
## Response: hemo_ri
## Sum Sq Df F value Pr(>F)
## (Intercept) 683.85 1 136.59 < 2.2e-16 ***
## days_from_molt 83.31 1 16.64 0.0001374 ***
## Residuals 295.39 59
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# linear models for significance testing
# r square of 0.22 -- weak correlation
# CML WL all data
ri_mod <- lm(hemo_ri ~ days_from_molt, data = molt_dat_2)
summary(ri_mod)
##
## Call:
## lm(formula = hemo_ri ~ days_from_molt, data = molt_dat_2)
##
## Residuals:
## Min 1Q Median 3Q Max
## -6.3149 -1.9204 -0.0513 1.9077 6.2279
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 6.94397 0.31375 22.132 < 2e-16 ***
## days_from_molt 0.08203 0.02587 3.171 0.00183 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.462 on 154 degrees of freedom
## (36 observations deleted due to missingness)
## Multiple R-squared: 0.06129, Adjusted R-squared: 0.0552
## F-statistic: 10.06 on 1 and 154 DF, p-value: 0.001834
anova(ri_mod)
## Analysis of Variance Table
##
## Response: hemo_ri
## Df Sum Sq Mean Sq F value Pr(>F)
## days_from_molt 1 60.96 60.960 10.055 0.001834 **
## Residuals 154 933.63 6.063
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
car::Anova(ri_mod, type = 3)
## Anova Table (Type III tests)
##
## Response: hemo_ri
## Sum Sq Df F value Pr(>F)
## (Intercept) 2969.63 1 489.833 < 2.2e-16 ***
## days_from_molt 60.96 1 10.055 0.001834 **
## Residuals 933.63 154
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# linear models for significance testing
# r square of 0.22 -- weak correlation
# WL 2022 data
plot(hemo_color ~ days_from_molt, data = molt_dat,
main = "Hemolymph Color as Green Crabs Approach Molt (n=13)",
xlim = rev(range(days_from_molt)),
xlab = "Days From Molt",
ylab = "Hemolymph Color")
abline(lm (hemo_color ~ days_from_molt, data = molt_dat), col = 4, lwd = 3)

boxplot(days_from_molt ~ hemo_color, data = molt_dat)

# plots hemo color vs days from molt for all 13 crabs
# need to reverse x axis to count down to molt
# doesn't appear to be strong trend or correlation
# WL 2022 data
library(ggplot2)
library(dplyr)
molt_dat %>%
# pipes molt data into ggplot
ggplot(aes(x = days_from_molt, y = hemo_color, colour = crab_id)) +
# populates plot with hemo color info and defines color with crab ID
geom_point() + geom_line() +
# specifies type of plot
scale_x_reverse() +
# reverses x axis so information counts down to molt
xlab("Days from molt") +
ylab ("Hemolymph Color") +
ggtitle("Hemolymph color as green crabs approach molt (n = 13") +
# renames x and y labels and title
labs(col = "Crab ID") + # changes legend title
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.background = element_blank())
## Warning: Removed 5 rows containing missing values (geom_point).
## Warning: Removed 5 row(s) containing missing values (geom_path).

# removes background grid from plot
# WL 2022 data
col_mod <- lm(hemo_color ~ days_from_molt, data = molt_dat)
summary(col_mod)
##
## Call:
## lm(formula = hemo_color ~ days_from_molt, data = molt_dat)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.96848 0.03152 0.16184 0.22198 2.16184
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.75797 0.19716 13.989 <2e-16 ***
## days_from_molt 0.01002 0.01701 0.589 0.558
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.8963 on 59 degrees of freedom
## (5 observations deleted due to missingness)
## Multiple R-squared: 0.005853, Adjusted R-squared: -0.011
## F-statistic: 0.3474 on 1 and 59 DF, p-value: 0.5579
anova(col_mod)
## Analysis of Variance Table
##
## Response: hemo_color
## Df Sum Sq Mean Sq F value Pr(>F)
## days_from_molt 1 0.279 0.27903 0.3474 0.5579
## Residuals 59 47.393 0.80327
car::Anova(col_mod, type = 3)
## Anova Table (Type III tests)
##
## Response: hemo_color
## Sum Sq Df F value Pr(>F)
## (Intercept) 157.187 1 195.6833 <2e-16 ***
## days_from_molt 0.279 1 0.3474 0.5579
## Residuals 47.393 59
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# linear models for significance testing
# WL 2022 data
# individual hemo color graphs over time
plot(hemo_color ~ days_from_molt, data = molt_dat,
subset = crab_id == "GBGB",
xlab = "Days From Molt",
ylab = "Hemolymph Color",
type = "b")

plot(hemo_color ~ days_from_molt, data = molt_dat,
subset = crab_id == "GBGG",
xlab = "Days From Molt",
ylab = "Hemolymph Color",
type = "b")

plot(hemo_color ~ days_from_molt, data = molt_dat,
subset = crab_id == "GBGB",
xlab = "Days From Molt",
ylab = "Hemolymph Color",
type = "b")

plot(hemo_color ~ days_from_molt, data = molt_dat,
subset = crab_id == "GBGY",
xlab = "Days From Molt",
ylab = "Hemolymph Color",
type = "b")

plot(hemo_color ~ days_from_molt, data = molt_dat,
subset = crab_id == "GBKR",
xlab = "Days From Molt",
ylab = "Hemolymph Color",
type = "b")

plot(hemo_color ~ days_from_molt, data = molt_dat,
subset = crab_id == "GBWK",
xlab = "Days From Molt",
ylab = "Hemolymph Color",
type = "b")

plot(hemo_color ~ days_from_molt, data = molt_dat,
subset = crab_id == "GBYB",
xlab = "Days From Molt",
ylab = "Hemolymph Color",
type = "b")

plot(hemo_color ~ days_from_molt, data = molt_dat,
subset = crab_id == "GGBR",
xlab = "Days From Molt",
ylab = "Hemolymph Color",
type = "b")

plot(hemo_color ~ days_from_molt, data = molt_dat,
subset = crab_id == "GGBY",
xlab = "Days From Molt",
ylab = "Hemolymph Color",
type = "b")

plot(hemo_color ~ days_from_molt, data = molt_dat,
subset = crab_id == "GGGW",
xlab = "Days From Molt",
ylab = "Hemolymph Color",
type = "b")

plot(hemo_color ~ days_from_molt, data = molt_dat,
subset = crab_id == "GGGY",
xlab = "Days From Molt",
ylab = "Hemolymph Color",
type = "b")

plot(hemo_color ~ days_from_molt, data = molt_dat,
subset = crab_id == "GGKG",
xlab = "Days From Molt",
ylab = "Hemolymph Color",
type = "b")

plot(hemo_color ~ days_from_molt, data = molt_dat,
subset = crab_id == "GGKR",
xlab = "Days From Molt",
ylab = "Hemolymph Color",
type = "b")

plot(hemo_color ~ days_from_molt, data = molt_dat,
subset = crab_id == "GGW",
xlab = "Days From Molt",
ylab = "Hemolymph Color",
type = "b")

# individual RI graphs over time
# appears that as crabs approach molt, RI decreases
plot(hemo_ri ~ days_from_molt, data = molt_dat,
subset = crab_id == "GBGB",
xlab = "Days From Molt",
type = "b")

plot(hemo_ri ~ days_from_molt, data = molt_dat,
subset = crab_id == "GBGG",
xlab = "Days From Molt",
ylab = "Hemolymph RI",
type = "b")

plot(hemo_ri ~ days_from_molt, data = molt_dat,
subset = crab_id == "GBGB",
xlab = "Days From Molt",
ylab = "Hemolymph RI",
type = "b")

plot(hemo_ri ~ days_from_molt, data = molt_dat,
subset = crab_id == "GBGY",
xlab = "Days From Molt",
ylab = "Hemolymph RI",
type = "b")

plot(hemo_ri ~ days_from_molt, data = molt_dat,
subset = crab_id == "GBKR",
xlab = "Days From Molt",
ylab = "Hemolymph RI",
type = "b")

plot(hemo_ri ~ days_from_molt, data = molt_dat,
subset = crab_id == "GBWK",
xlab = "Days From Molt",
ylab = "Hemolymph RI",
type = "b")

plot(hemo_ri ~ days_from_molt, data = molt_dat,
subset = crab_id == "GBYB",
xlab = "Days From Molt",
ylab = "Hemolymph RI",
type = "b")

plot(hemo_ri ~ days_from_molt, data = molt_dat,
subset = crab_id == "GGBR",
xlab = "Days From Molt",
ylab = "Hemolymph RI",
type = "b")

plot(hemo_ri ~ days_from_molt, data = molt_dat,
subset = crab_id == "GGBY",
xlab = "Days From Molt",
ylab = "Hemolymph RI",
type = "b")

plot(hemo_ri ~ days_from_molt, data = molt_dat,
subset = crab_id == "GGGW",
xlab = "Days From Molt",
ylab = "Hemolymph RI",
type = "b")

plot(hemo_ri ~ days_from_molt, data = molt_dat,
subset = crab_id == "GGGY",
xlab = "Days From Molt",
ylab = "Hemolymph RI",
type = "b")

plot(hemo_ri ~ days_from_molt, data = molt_dat,
subset = crab_id == "GGKG",
xlab = "Days From Molt",
ylab = "Hemolymph RI",
type = "b")

plot(hemo_ri ~ days_from_molt, data = molt_dat,
subset = crab_id == "GGKR",
xlab = "Days From Molt",
ylab = "Hemolymph RI",
type = "b")

plot(hemo_ri ~ days_from_molt, data = molt_dat,
subset = crab_id == "GGW",
xlab = "Days From Molt",
ylab = "Hemolymph RI",
type = "b")
